package com.kevin.entity;

import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class User {
    public final static int USER_TYPE_ADMIN=3;
    public final static int USER_TYPE_AGENT=2;
    public final static int USER_TYPE_NOMAL=1;
    public final static String PASSWORD_DEFAULT="e10adc3949ba59abbe56e057f20f883e";//默认MD5密码 123456
    public final static int ONLINE=1;//在线
    public final static int OFFLINE=0;//离线
    
    private Integer id;

    private String userName;

    private String loginName;

    private String password;

    private Integer sex;

    private String mobile;

    private String province;

    private String city;

    private String provinceName;

    private String cityName;

    private String companyName;

    private String qq;

    private String webSite;

    private String description;

    private Integer enabled;

    private Integer locked;

    private Integer creator;

    private Date createDate;

    private Integer modificator;

    private Date modifyDate;

    private String passwordz;

    private Double money;

    private Integer moneyLock;
    
    private Integer bank;

    private String bankcard;

    private Integer infolocked;

    private Integer userType;

    private String pid;
    
    private Integer reference;
    
    private String bankName;
    
    private String userTypeName;
    
    private String pidName;
    
    private Integer online;
    
    private String onlineText;
    
    private Date loginDate;
    
    private Date logoutDate;
    
    /**
     * 返点
     */
    private Double rebate;
    
    /**
     * 不定位返点
     */
    private Double rebateBdw;
    /**
     * 返点锁定
     */
    private Integer rebateLock;
    
    
    /**
     * 用户所属
     */
    private String pidText;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName == null ? null : loginName.trim();
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password == null ? null : password.trim();
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile == null ? null : mobile.trim();
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province == null ? null : province.trim();
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city == null ? null : city.trim();
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName == null ? null : provinceName.trim();
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName == null ? null : cityName.trim();
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName == null ? null : companyName.trim();
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq == null ? null : qq.trim();
    }

    public String getWebSite() {
        return webSite;
    }

    public void setWebSite(String webSite) {
        this.webSite = webSite == null ? null : webSite.trim();
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description == null ? null : description.trim();
    }

    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    public Integer getLocked() {
        return locked;
    }

    public void setLocked(Integer locked) {
        this.locked = locked;
    }



    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Integer getCreator() {
		return creator;
	}

	public void setCreator(Integer creator) {
		this.creator = creator;
	}

	public Integer getModificator() {
		return modificator;
	}

	public void setModificator(Integer modificator) {
		this.modificator = modificator;
	}

	public Date getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(Date modifyDate) {
        this.modifyDate = modifyDate;
    }

    public String getPasswordz() {
        return passwordz;
    }

    public void setPasswordz(String passwordz) {
        this.passwordz = passwordz == null ? null : passwordz.trim();
    }

    public Double getMoney() {
        return money;
    }

    public void setMoney(Double money) {
        this.money = money;
    }

    public Integer getBank() {
        return bank;
    }

    public void setBank(Integer bank) {
        this.bank = bank;
    }

    public String getBankcard() {
        return bankcard;
    }

    public void setBankcard(String bankcard) {
        this.bankcard = bankcard == null ? null : bankcard.trim();
    }

    public Integer getInfolocked() {
        return infolocked;
    }

    public void setInfolocked(Integer infolocked) {
        this.infolocked = infolocked;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid == null ? null : pid.trim();
    }

    public Integer getReference() {
		return reference;
	}

	public void setReference(Integer reference) {
		this.reference = reference;
	}

	public String getBankName() {
        if(this.bank!=null){
            switch(bank){
             case 1:
                return "工商银行";
             case 2:
                return "农业银行";
             case 3:
                return "建设银行";
             case 4:
                return "中国银行";
             case 5:
                return "邮政储蓄";
             default:
                return "";
            }
        }
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public Double getRebate() {
        return rebate;
    }

    public void setRebate(Double rebate) {
        this.rebate = rebate;
    }

    public Double getRebateBdw() {
        return rebateBdw;
    }

    public void setRebateBdw(Double rebateBdw) {
        this.rebateBdw = rebateBdw;
    }

    public String getUserTypeName() {
        if(userType==null)
            return "";
        else if(userType==1){
            return "会员";
        }else if(userType==2){
            return "代理";
        }else if(userType==3){
            return "管理";
        }
        return userTypeName;
    }

    public String getPidName() {
        return pidName;
    }

    public void setPidName(String pidName) {
        this.pidName = pidName;
    }

    public Integer getOnline() {
        return online;
    }

    public void setOnline(Integer online) {
        this.online = online;
    }

    public String getOnlineText() {
        if(online!=null){
            if(online==1)
                return "在线";
            else if(online==0)
                return "离线";
        }else{
            return "离线";
//            return "非正常离线";
        }
        return onlineText;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public Date getLogoutDate() {
        return logoutDate;
    }

    public void setLogoutDate(Date logoutDate) {
        this.logoutDate = logoutDate;
    }

	public Integer getMoneyLock() {
		return moneyLock;
	}

	public void setMoneyLock(Integer moneyLock) {
		this.moneyLock = moneyLock;
	}

	public String getPidText() {
		return pidText;
	}

	public void setPidText(String pidText) {
		this.pidText = pidText;
	}
	
	

	/**
	 * 获取父节点数组最后一个节点
	 * @return
	 */
	public Integer getPidLast() {
		Integer[] arr = getPidArray();
		if(arr==null)
			return null;
		return arr[arr.length-1];	
	}
	

	/**
	 * 获取父节点数组
	 * "|1|2|3|" to [1,2,3]
	 * @return
	 */
	public Integer[] getPidArray() {
		if(StringUtils.isBlank(pid))
			return null;
		String[] split =pid.split("\\|");
		int len = split.length;
		Integer[] arr=new Integer[len-1];
		for(int i=0;i<arr.length;i++){
			arr[i]=Integer.parseInt(split[i+1]);//split数组第一个元素为空
		}
		return arr;
	}

    public Integer getRebateLock() {
        return rebateLock;
    }

    public void setRebateLock(Integer rebateLock) {
        this.rebateLock = rebateLock;
    }
	
	
}